<?xml version="1.0" encoding="IBM437"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta content="text/html; charset=IBM437" http-equiv="Content-Type" />

  <title>Class: Vizi::LogFormat</title>

  <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />

  <script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/darkfish.js" type="text/javascript" charset="utf-8"></script>

</head>
<body id="top" class="class">

  <div id="metadata">
    <div id="home-metadata">
      <div id="home-section" class="section">
        <h3 class="section-header">
          <a href="../index.html">Home</a>
          <a href="../index.html#classes">Classes</a>
          <a href="../index.html#methods">Methods</a>
        </h3>
      </div>
    </div>

    <div id="file-metadata">
      <div id="file-list-section" class="section">
        <h3 class="section-header">In Files</h3>
        <div class="section-body">
          <ul>
          
            <li><a href="../lib/vizi/vizi_tracker_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
              class="thickbox" title="lib/vizi/vizi_tracker.rb">lib/vizi/vizi_tracker.rb</a></li>
          
          </ul>
        </div>
      </div>

      
    </div>

    <div id="class-metadata">
      
      <!-- Parent Class -->
      <div id="parent-class-section" class="section">
        <h3 class="section-header">Parent</h3>
        
        <p class="link"><a href="../Object.html">Object</a></p>
        
      </div>
      

      

      

      
      <!-- Method Quickref -->
      <div id="method-list-section" class="section">
        <h3 class="section-header">Methods</h3>
        <ul class="link-list">
          
          <li><a href="#method-c-new">::new</a></li>
          
          <li><a href="#method-i-parse_format">#parse_format</a></li>
          
          <li><a href="#method-i-process_directive">#process_directive</a></li>
          
        </ul>
      </div>
      

      
    </div>

    <div id="project-metadata">
      
      
      <div id="fileindex-section" class="section project-section">
        <h3 class="section-header">Files</h3>
        <ul>
        
          <li class="file"><a href="../README_rdoc.html">README.rdoc</a></li>
        
          <li class="file"><a href="../Rakefile.html">Rakefile</a></li>
        
        </ul>
      </div>
      

      <div id="classindex-section" class="section project-section">
        <h3 class="section-header">Class/Module Index
          <span class="search-toggle"><img src="../images/find.png"
            height="16" width="16" alt="[+]"
            title="show/hide quicksearch" /></span></h3>
        <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
        <fieldset>
          <legend>Quicksearch</legend>
          <input type="text" name="quicksearch" value=""
            class="quicksearch-field" />
        </fieldset>
        </form>

        <ul class="link-list">
        
          <li><a href="../Vizi.html">Vizi</a></li>
        
          <li><a href="../Vizi/LogFormat.html">Vizi::LogFormat</a></li>
        
          <li><a href="../Vizi/LogParser.html">Vizi::LogParser</a></li>
        
          <li><a href="../Vizi/Visit.html">Vizi::Visit</a></li>
        
          <li><a href="../Vizi/VisitList.html">Vizi::VisitList</a></li>
        
          <li><a href="../Object.html">Object</a></li>
        
          <li><a href="../ParserTest.html">ParserTest</a></li>
        
        </ul>
        <div id="no-class-search-results" style="display: none;">No matching classes.</div>
      </div>

      
    </div>
  </div>

  <div id="documentation">
    <h1 class="class">Vizi::LogFormat</h1>

    <div id="description" class="description">
      
<p>This class handles the parsing of each line in the log file</p>

    </div><!-- description -->

    
    <div id="5Buntitled-5D" class="documentation-section">
      

      

      
      <!-- Constants -->
      <div id="constants-list" class="section">
        <h3 class="section-header">Constants</h3>
        <dl>
        
          <dt><a name="DIRECTIVES">DIRECTIVES</a></dt>
          
          <dd class="description"><p>add more format directives here..</p></dd>
          
        
        </dl>
      </div>
      

      
      <!-- Attributes -->
      <div id="attribute-method-details" class="method-section section">
        <h3 class="section-header">Attributes</h3>

        
        <div id="format-attribute-method" class="method-detail">
          <a name="format"></a>
          
          <div class="method-heading attribute-method-heading">
            <span class="method-name">format</span><span
              class="attribute-access-type">[R]</span>
          </div>

          <div class="method-description">
          
          
          
          </div>
        </div>
        
        <div id="format_regex-attribute-method" class="method-detail">
          <a name="format_regex"></a>
          
          <div class="method-heading attribute-method-heading">
            <span class="method-name">format_regex</span><span
              class="attribute-access-type">[R]</span>
          </div>

          <div class="method-description">
          
          
          
          </div>
        </div>
        
        <div id="format_symbols-attribute-method" class="method-detail">
          <a name="format_symbols"></a>
          
          <div class="method-heading attribute-method-heading">
            <span class="method-name">format_symbols</span><span
              class="attribute-access-type">[R]</span>
          </div>

          <div class="method-description">
          
          
          
          </div>
        </div>
        
        <div id="name-attribute-method" class="method-detail">
          <a name="name"></a>
          
          <div class="method-heading attribute-method-heading">
            <span class="method-name">name</span><span
              class="attribute-access-type">[R]</span>
          </div>

          <div class="method-description">
          
          
          
          </div>
        </div>
        
      </div><!-- attribute-method-details -->
      

      <!-- Methods -->
      
      <div id="public-class-method-details" class="method-section section">
        <h3 class="section-header">Public Class Methods</h3>

      
        <div id="new-method" class="method-detail ">
          <a name="method-c-new"></a>

          
          <div class="method-heading">
            <span class="method-name">new</span><span
              class="method-args">(name, format)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="new-source">
<pre>
<span class="ruby-comment"># File lib/vizi/vizi_tracker.rb, line 43</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">format</span>)
  <span class="ruby-ivar">@name</span>, <span class="ruby-ivar">@format</span> = <span class="ruby-identifier">name</span>, <span class="ruby-identifier">format</span>
  <span class="ruby-identifier">parse_format</span>(<span class="ruby-identifier">format</span>)
<span class="ruby-keyword">end</span></pre>
            </div><!-- new-source -->
            
          </div>

          

          
        </div><!-- new-method -->

      
      </div><!-- public-class-method-details -->
    
      <div id="public-instance-method-details" class="method-section section">
        <h3 class="section-header">Public Instance Methods</h3>

      
        <div id="parse_format-method" class="method-detail ">
          <a name="method-i-parse_format"></a>

          
          <div class="method-heading">
            <span class="method-name">parse_format</span><span
              class="method-args">(format)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>The symbols are used to map the log to the env variables The regex is used
when checking what format the log is and to extract data</p>
            

            
            <div class="method-source-code" id="parse_format-source">
<pre>
<span class="ruby-comment"># File lib/vizi/vizi_tracker.rb, line 50</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">parse_format</span>(<span class="ruby-identifier">format</span>)
  <span class="ruby-identifier">format_directive</span> = <span class="ruby-node">/%(.*?)(\{.*?\})?([#{[DIRECTIVES.keys.join('|')]}])([\s\\&quot;]*)/</span>
  <span class="ruby-identifier">log_format_symbols</span> = []
  <span class="ruby-identifier">format_regex</span> = <span class="ruby-string">&quot;&quot;</span>
  <span class="ruby-identifier">format</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-identifier">format_directive</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">condition</span>, <span class="ruby-identifier">subdirective</span>, <span class="ruby-identifier">directive_char</span>, <span class="ruby-identifier">ignored</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">log_format</span>, <span class="ruby-identifier">match_regex</span> = <span class="ruby-identifier">process_directive</span>(<span class="ruby-identifier">directive_char</span>, <span class="ruby-identifier">subdirective</span>, <span class="ruby-identifier">condition</span>)
    <span class="ruby-identifier">ignored</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp">/\s/</span>, <span class="ruby-string">'\s'</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">ignored</span>.<span class="ruby-identifier">nil?</span>
    <span class="ruby-identifier">log_format_symbols</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">log_format</span>
    <span class="ruby-identifier">format_regex</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;(#{match_regex})#{ignored}&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-ivar">@format_symbols</span> = <span class="ruby-identifier">log_format_symbols</span>
  <span class="ruby-ivar">@format_regex</span> = <span class="ruby-node">/^#{format_regex}/</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- parse_format-source -->
            
          </div>

          

          
        </div><!-- parse_format-method -->

      
        <div id="process_directive-method" class="method-detail ">
          <a name="method-i-process_directive"></a>

          
          <div class="method-heading">
            <span class="method-name">process_directive</span><span
              class="method-args">(directive_char, subdirective, condition)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="process_directive-source">
<pre>
<span class="ruby-comment"># File lib/vizi/vizi_tracker.rb, line 64</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">process_directive</span>(<span class="ruby-identifier">directive_char</span>, <span class="ruby-identifier">subdirective</span>, <span class="ruby-identifier">condition</span>)
  <span class="ruby-identifier">directive</span> = <span class="ruby-constant">DIRECTIVES</span>[<span class="ruby-identifier">directive_char</span>]
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">directive_char</span>
    <span class="ruby-keyword">when</span> <span class="ruby-string">'i'</span>
      <span class="ruby-identifier">log_format</span> = <span class="ruby-identifier">subdirective</span>[<span class="ruby-value">1</span><span class="ruby-operator">...</span><span class="ruby-value">-1</span>].<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">tr</span>(<span class="ruby-string">'-'</span>, <span class="ruby-string">'_'</span>).<span class="ruby-identifier">to_sym</span>
      [<span class="ruby-identifier">log_format</span>, <span class="ruby-identifier">directive</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">source</span>]
    <span class="ruby-keyword">else</span>
      [<span class="ruby-identifier">directive</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">directive</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">source</span>]
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- process_directive-source -->
            
          </div>

          

          
        </div><!-- process_directive-method -->

      
      </div><!-- public-instance-method-details -->
    
    </div><!-- 5Buntitled-5D -->
  

  </div><!-- documentation -->

  <div id="validator-badges">
    <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
    <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
      Rdoc Generator</a> 2</small>.</p>
  </div>

</body>
</html>

